package com.chcit.share.admin.service.impl;

import java.util.List;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chcit.share.admin.core.page.MybatisPageHelper;
import com.chcit.share.admin.core.page.PageRequest;
import com.chcit.share.admin.core.page.PageResult;

import com.chcit.share.admin.model.SysConfig;
import com.chcit.share.admin.dao.SysConfigMapper;
import com.chcit.share.admin.service.SysConfigService;

/**
 * ---------------------------
 *  (SysConfigServiceImpl)         
 * ---------------------------
 * 作者：  share-generator
 * 时间：  2019-04-05 01:48:06
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class SysConfigServiceImpl implements SysConfigService {

	@Autowired
	private SysConfigMapper sysConfigMapper;

	@Override
	public int save(SysConfig record) {
		if(StrUtil.isNotBlank(record.getVariable())) {
			return sysConfigMapper.add(record);
		}
		return sysConfigMapper.update(record);
	}

	@Override
	public int delete(SysConfig record) {
		return sysConfigMapper.delete(record.getVariable());
	}

	@Override
	public int delete(List<SysConfig> records) {
		for(SysConfig record:records) {
			delete(record);
		}
		return 1;
	}


	@Override
	public SysConfig findById(Long id) {
		return sysConfigMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, sysConfigMapper);
	}
	
}
